/**
 * 
 */
package net.loyintean.pearlshell.logcenter.jms;

import net.loyintean.pearlshell.logcenter.jms.activemq.FixedJmsSenderFactoryImpl;
import net.loyintean.pearlshell.logcenter.jms.activemq.MultiJmsSenderFacotryImpl;
import net.loyintean.pearlshell.logcenter.model.IConfigModel;

/**
 * @author Administrator
 * 
 */
public abstract class IJmsSenderFactory {

	private static IJmsSenderFactory FIXED_FACTORY = new FixedJmsSenderFactoryImpl(),
			MULTI_FACTORY = new MultiJmsSenderFacotryImpl();

	@Deprecated
	public abstract IJmsSender create(String url, String destinationName);

	public abstract IJmsSender create(IConfigModel config);

	public static final IJmsSenderFactory getFactory(String factoryname) {

		if ("FIXED".equals(factoryname)) {

			if (FIXED_FACTORY == null) {
				FIXED_FACTORY = new FixedJmsSenderFactoryImpl();
			}
			return FIXED_FACTORY;
		} else if ("MULTI".equals(factoryname)) {

			if (MULTI_FACTORY == null) {
				MULTI_FACTORY = new MultiJmsSenderFacotryImpl();
			}
			return MULTI_FACTORY;
		}

		return null;
	}
}
